﻿/**
 * Copyright (C) 2011 original author and authors
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace NGuice.Inject.Spi
{
    //complete!
    /// <summary>
    /// 一个模块或者注入器的核心组件。一个模块的元素能够被注入，验证和重写。使用
    /// <code>Elements.GetElements(Module[])</code>方法从模块中读取元素。使用
    /// <code>Elements.GetModule</code>方法重写。这能够被用于静态分析和NGuice
    /// 模块的生成。注入器的元素能够被内省，可以使用<code>Injector.GetBindings</code>
    /// 反射NGuice注入器
    /// </summary>
    public interface IElement
    {
        /// <summary>
        /// 返回包含此元素被配置的位置（place）的信息的任意对象。被NGuice使用在产品中描述错误消息。
        /// 工具应该指定他们知晓的处理类型。例如：StackFrame。如果类型是未知的，工具应该简单调用
        /// source上的ToString
        /// </summary>
        object Source 
        {
           get;
        }

        /// <summary>
        /// 接收元素访问者的访问
        /// </summary>
        T AcceptVisitor<T>(IElementVisitor<T> visitor);
        
        /// <summary>
        /// 将此模块元素写入到给定绑定器（可选操作）
        /// </summary>
        /// <exception cref="NotSupportedException">如果不支持则抛出此异常</exception>
        void ApplyTo(IBinder binder);
    }
}
